﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>授权详细信息</title>
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/components-rounded.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/themes/default/style.min.css" rel="stylesheet" />
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.cokie.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <!--时间-->
    <script src="../Comm/JS/Calendar/WdatePicker.js" type="text/javascript"></script>
    <link href="../Comm/JS/Calendar/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
    <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>

    <script type="text/javascript" language="javascript">
        //页面启动函数.
        var webUser = null;
        var emp = null;

        $(function () {

            webUser = new WebUser();

            var ens = new Entities("BP.WF.Auths");
            ens.Retrieve("Auther", webUser.No);

            var html = "<div class='container'>";
            html += "<div class='fixed-table-header '>";
            html += "<table class='table table-hover table-striped ' >";
            html += "<caption style='height:auto;text-indent: 0em;'> [" + webUser.No + "]授权列表  <a href='AuthorDtl.htm' >+增加授权列表</a> </caption>";

            html += "<thead ><tr> ";
            html += "<th style='background-color:#F2F2F2;'>序</th>";
            html += "<th style='background-color:#F2F2F2;'>授权给</th>";
            html += "<th style='background-color:#F2F2F2;'>授权类型</th>";
            //html += "<th style='background-color:#F2F2F2;'>流程</th>";
            html += "<th style='background-color:#F2F2F2;'>收回日期</th>";
            html += "<th style='background-color:#F2F2F2;'>状态</th>";
            html += "<th colspan='2' style='background-color:#F2F2F2;text-align:center'>操作</th>";
            html += "</tr></thead>";

            html += "<tbody>";
            var takeBackDT = "";
            var num = 1;
            for (var i = 0; i < ens.length; i++) {

                en = ens[i];
                //指定流程时，授权时间不同，可能会有多条合并流程的记录
                if (en.AuthType == 2) {
                    if (takeBackDT.indexOf(en.TakeBackDT + ",") != -1) {
                        continue;
                    }
                    takeBackDT += en.TakeBackDT + ",";
                }

                var AuthType = en.AuthType;
                var AuthTypeName;
                switch (AuthType) {
                    case 0: AuthTypeName = '不授权'; break;
                    case 1: AuthTypeName = '全部流程授权'; break;
                    case 2: AuthTypeName = '指定流程授权'; break;
                    default: AuthTypeName = '空';
                }
                var nowDate = getNowFormatDate();
                var state = "";
                if (checkTime(nowDate,en.TakeBackDT)) {
                    state = "<lable style='color:green'>授权中</lable>";
                } else {
                    state = "<lable style='color:red'>已收回</lable>";
                }

                html += "<tr>";
                html += "<td>" + num + "</td>";
                html += "<td>" + en.AutherToEmpName + "</td>";
                html += "<td>" + AuthTypeName + "</td>";
                //if (en.AuthType == 2) {
                //    html += "<td>" + flowName + "</td>";
                //} else {
                //    html += "<td>" + en.FlowName + "</td>";
                //}
                html += "<td>" + en.TakeBackDT + "</td>";
                html += "<td>" + state + "</td>";
                var MyPK = en.Auther + "_" + en.AuthType + "_" + en.AutherToEmpNo;
                html += "<td style='text-align:center'><a href=\"javascript:Del('" + MyPK + "')\">删除</a></td>";
                html += "<td style='text-align:center'><a href='AuthorDtl.htm?UpdateInfo=1&AutherToEmpNo=" + en.AutherToEmpNo + "&AutherToEmpName=" + en.AutherToEmpName + "&AuthType=" + en.AuthType + "&TakeBackDT=" + en.TakeBackDT+"' >修改</a></td>";
                html += "</tr>";
                num++;
            }

            html += "</tbody>";
            html += "</table>";
            html += "</div>";
            html += "</div>";
            $("#docs").html(html);

        });

        //执行删除.
        function Del(MyPK) {
            if (window.confirm('您确定要删除吗？') == false)
                return;
            var Auth = new Entity("BP.WF.Auth", MyPK);
            var res = Auth.Delete();
            if (res == 1) {
                alert("删除成功");
                window.location.href = window.location.href;
            }
            else {
                alert("删除失败");
            }

        }

        //获取当前时间
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            //当前时间=年份-月份-日 小时：分钟
            var cdt = date.getFullYear() + seperator1 + month + seperator1 + strDate;
            //+ " " + date.getHours() + seperator2 + date.getMinutes();

            return cdt;
        }

        //比较时间
        function checkTime(startDT,endDT) {
            var startTime = startDT;
            var start = new Date(startTime.replace("-", "/").replace("-", "/"));
            var endTime = endDT;
            var end = new Date(endTime.replace("-", "/").replace("-", "/"));
            if (end < start) {
                return false;
            }
            return true;
        }


    </script>
</head>
<body onkeypress="Esc()" class="gray-bg">
    <form id="cc" name="cc">
        <div id="docs"></div>

    </form>
</body>
</html>
